<template>
  <!-- router-link-active router-link-exact-active -->
  <!-- <router-link :to="path"> -->
    <el-submenu v-if="list.children" :index="index">
      <template slot="title">
        <!-- <el-menu-item> -->
          <i class="el-icon-location"></i>
          <span slot="title">
            {{list.label}}
          </span>
        <!-- </el-menu-item> -->
      </template>
      <template v-for="(item, idx) in list.children">
        <!-- 当前路由访问获取不到数据 需要从父级传入 -->
        <tree-menu :list="item" :index="index + '/' + item.path" :key='idx'>
        <!-- <tree-menu :list="item" :path="item.path" :index="index + '-' + idx" :key='idx'>
        <router-link append></router-link> to push repalce append -->
        </tree-menu>
      </template>
    </el-submenu>
    <el-menu-item v-else :index="index">
      <i class="el-icon-setting"></i>
      <span slot="title">
        {{list.label}}
      </span>
    </el-menu-item>
  <!-- </router-link> -->
</template>

<script>
import { constantRoutes } from '@/router'
export default {
  // name 属性指向组件实例
  data() {
    return {
      n: 0,
    }
  },
  name: "treeMenu",
  props: {
    list: {},
    index: {},
    path: {},
  }
}
</script>

<style lang="scss" scoped>
  .router-link-active {
    color: #409eff!important;
  }
</style>

